package com.itheima.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo3 {
    public static void main(String[] args) {
        Map<String, String> m = new HashMap<>();
        m.put("1号丈夫", "1号妻子");
        m.put("2号丈夫", "2号妻子");
        m.put("3号丈夫", "3号妻子");
        m.put("4号丈夫", "4号妻子");
        m.put("5号丈夫", "5号妻子");

        Set<String> s = m.keySet();
        for (String h : s) {
            String w = m.get(h);
            System.out.println(h + "-->" + w);
        }
        System.out.println("-----------------------");

        Set<Map.Entry<String, String>> entries = m.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"-->"+value);
        }
        System.out.println("-----------------------");

        m.forEach((k,v)->
            System.out.println(k + "-->" + v));
    }
}
